import unittest


# 学习yield语法
class MyTestCase(unittest.TestCase):

    def test_next(self):
        def my_gen():
            # 创建一个迭代器
            yield 1
            yield 2
            yield 3

        g = my_gen()
        self.assertEqual(next(g), 1)
        self.assertEqual(next(g), 2)
        self.assertEqual(next(g), 3)

        # 移除错误的断言，因为 next(g) 应该在此时抛出 StopIteration 异常
        # self.assertEqual(next(g), None)

        # 可以改为检查 StopIteration 异常是否被抛出
        try:
            next(g)
            self.fail("Expected StopIteration exception was not raised.")
        except StopIteration:
            pass  # 正确捕获了 StopIteration 异常，测试通过

    def test_something(self):
        self.assertEqual(True, True)  # add assertion here
